Moving clear all button inside the recents view

Bug: 72222505
Bug: 109828536

Change-Id: I843b79db3e47abc2c41ed78f186b9c941941ddef
This commit is contained in:
Sunny Goyal committed 2018-06-11 13:51:03 -07:00
1 parent 367a53ec13
commit c82c6396e9
23 files changed
+249 -484

No files matched your search

@@ -17,34 +17,57 @@
package com.android.quickstep.views;
import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
public class ClearAllButton extends Button {
RecentsView mRecentsView;
import com.android.launcher3.Utilities;
import com.android.quickstep.views.RecentsView.PageCallbacks;
import com.android.quickstep.views.RecentsView.ScrollState;
public ClearAllButton(Context context, @Nullable AttributeSet attrs) {
public class ClearAllButton extends Button implements PageCallbacks {
private float mScrollAlpha = 1;
private float mContentAlpha = 1;
private final boolean mIsRtl;
private int mScrollOffset;
public ClearAllButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setRecentsView(RecentsView recentsView) {
mRecentsView = recentsView;
mIsRtl = Utilities.isRtl(context.getResources());
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setParent(mRecentsView); // Pretend we are a part of the task carousel.
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
RecentsView parent = (RecentsView) getParent();
mScrollOffset = mIsRtl ? parent.getPaddingRight() / 2 : - parent.getPaddingLeft() / 2;
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
if (focused) {
mRecentsView.revealClearAllButton();
public boolean hasOverlappingRendering() {
return false;
}
public void setContentAlpha(float alpha) {
if (mContentAlpha != alpha) {
mContentAlpha = alpha;
setAlpha(mScrollAlpha * mContentAlpha);
}
}
@Override
public void onPageScroll(ScrollState scrollState) {
float width = getWidth();
if (width == 0) {
return;
}
float shift = Math.min(scrollState.scrollFromEdge, width);
setTranslationX(mIsRtl ? (mScrollOffset - shift) : (mScrollOffset + shift));
mScrollAlpha = 1 - shift / width;
setAlpha(mScrollAlpha * mContentAlpha);
}
}