Add a header container view to the widgets full sheet

A header container view will contain
1. A horizontal bar: for indicating the popup view can be dragged
   to dismiss:
2. A title view: a title of the widgets full sheet popup view.
3. A search bar: for widgets / shortcut search. Since we will be
   making the fallback search algorithm available in AOSP, the
   search bar will now live in the Launcher3 codebase.
4. Recommended widgets (coming soon...)

This CL also added a scroll effect which gradually collapses the
title view when the user scrolls down the recycler view. The title
view will gradually restore its height when the user scroll to the
top of the recycler view.

Test: Manually test widgets pickers in work profile and non work
      profile setup. Verified the fast scroll bar works well in
      both setup.
      With searchbar: https://drive.google.com/file/d/19grUHL_LspLhMD_5p6-i0CiMW1FpflmD/view?usp=sharing
      Without searchbar: https://drive.google.com/file/d/1KRPgEAESHUhJDo1UJsQN80JO1c9Y8Nhl/view?usp=sharing

Bug: 179797520

Change-Id: If0016e3b3c693414897140e7912531ed9bd5deef
This commit is contained in:
Steven Ng
2021-02-23 10:48:46 +00:00
parent 036b585475
commit 167f81b931
11 changed files with 375 additions and 28 deletions

View File

@@ -34,6 +34,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.BaseRecyclerView;
@@ -99,6 +100,7 @@ public class RecyclerViewFastScroller extends View {
private boolean mIsThumbDetached;
private final boolean mCanThumbDetach;
private boolean mIgnoreDragGesture;
private boolean mIsRecyclerViewFirstChildInParent = true;
// This is the offset from the top of the scrollbar when the user first starts touching. To
// prevent jumping, this offset is applied as the user scrolls.
@@ -112,6 +114,7 @@ public class RecyclerViewFastScroller extends View {
protected BaseRecyclerView mRv;
private RecyclerView.OnScrollListener mOnScrollListener;
@Nullable private OnFastScrollChangeListener mOnFastScrollChangeListener;
private int mDownX;
private int mDownY;
@@ -188,6 +191,9 @@ public class RecyclerViewFastScroller extends View {
updatePopupY(y);
mThumbOffsetY = y;
invalidate();
if (mOnFastScrollChangeListener != null) {
mOnFastScrollChangeListener.onThumbOffsetYChanged(mThumbOffsetY);
}
}
public int getThumbOffsetY() {
@@ -391,7 +397,9 @@ public class RecyclerViewFastScroller extends View {
return false;
}
getHitRect(sTempRect);
sTempRect.top += mRv.getScrollBarTop();
if (mIsRecyclerViewFirstChildInParent) {
sTempRect.top += mRv.getScrollBarTop();
}
if (outOffset != null) {
outOffset.set(sTempRect.left, sTempRect.top);
}
@@ -404,4 +412,23 @@ public class RecyclerViewFastScroller extends View {
// alpha is so low, it does not matter.
return false;
}
public void setIsRecyclerViewFirstChildInParent(boolean isRecyclerViewFirstChildInParent) {
mIsRecyclerViewFirstChildInParent = isRecyclerViewFirstChildInParent;
}
public void setOnFastScrollChangeListener(
@Nullable OnFastScrollChangeListener onFastScrollChangeListener) {
mOnFastScrollChangeListener = onFastScrollChangeListener;
}
/**
* A callback that is invoked when there is a scroll change in {@link RecyclerViewFastScroller}.
*/
public interface OnFastScrollChangeListener {
/**
* Called when the thumb offset vertical position, in pixels, has changed to {@code y}.
*/
void onThumbOffsetYChanged(int y);
}
}