Converting widget panel into a floating view

> The widget panel is only inflated when needed
> Using the swipe up/down interaction for widgets tray
> Removing additional view wrappers from all-apps
> Widget tray is preserved across activity recreation
> Launcher no longer has WIDGET state, the actual code around
  the states will be removed in a follow-up cl

Bug: 67678570
Bug: 67585158
Change-Id: Ia29a7c33ec81e6c53cc24e2906b7022b6f41755b
This commit is contained in:
Sunny Goyal
2017-10-10 15:21:15 -07:00
parent 10a1bd0e65
commit f1fbc3fbe7
33 changed files with 1026 additions and 1611 deletions

View File

@@ -21,6 +21,7 @@ import android.graphics.Canvas;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -99,11 +100,15 @@ public abstract class BaseRecyclerView extends RecyclerView
// DO NOT REMOVE, NEEDED IMPLEMENTATION FOR M BUILDS
}
public int getScrollBarTop() {
return getPaddingTop();
}
/**
* Returns the height of the fast scroll bar
*/
public int getScrollbarTrackHeight() {
return getHeight() - getPaddingTop() - getPaddingBottom();
return getHeight() - getScrollBarTop() - getPaddingBottom();
}
/**
@@ -121,13 +126,6 @@ public abstract class BaseRecyclerView extends RecyclerView
return availableScrollBarHeight;
}
/**
* Returns the scrollbar for this recycler view.
*/
public RecyclerViewFastScroller getScrollBar() {
return mScrollbar;
}
@Override
protected void dispatchDraw(Canvas canvas) {
onUpdateScrollbar(0);
@@ -159,6 +157,28 @@ public abstract class BaseRecyclerView extends RecyclerView
mScrollbar.setThumbOffsetY(scrollBarY);
}
/**
* Returns whether the view itself will handle the touch event or not.
* @param ev MotionEvent in {@param eventSource}
*/
public boolean shouldContainerScroll(MotionEvent ev, View eventSource) {
int[] point = new int[2];
point[0] = (int) ev.getX();
point[1] = (int) ev.getY();
Utilities.mapCoordInSelfToDescendant(mScrollbar, eventSource, point);
// IF the MotionEvent is inside the thumb, container should not be pulled down.
if (mScrollbar.shouldBlockIntercept(point[0], point[1])) {
return false;
}
// IF scroller is at the very top OR there is no scroll bar because there is probably not
// enough items to scroll, THEN it's okay for the container to be pulled down.
if (getCurrentScrollY() == 0) {
return true;
}
return false;
}
/**
* @return whether fast scrolling is supported in the current state.
*/