Adding support for top padding in BaseRecyclerView. The scrollbar is drawn below the top padding. Also adding callback for getting the all-apps vertical pull range so that it can be controlled by SearchUiManager
am: dc19a07aba
Change-Id: I8fda544ee42fcb330611519b1546e574fbd83c81
This commit is contained in:
commit
a485df1275
|
@ -48,11 +48,6 @@
|
|||
<dimen name="resize_frame_background_padding">24dp</dimen>
|
||||
|
||||
<!-- Container -->
|
||||
<!-- Note: This needs to match the fixed insets for the search box. -->
|
||||
<dimen name="container_bounds_inset">8dp</dimen>
|
||||
<!-- Notes: container_bounds_inset - quantum_panel_outer_padding -->
|
||||
<dimen name="container_bounds_minus_quantum_panel_padding_inset">4dp</dimen>
|
||||
|
||||
<dimen name="container_fastscroll_thumb_min_width">5dp</dimen>
|
||||
<dimen name="container_fastscroll_thumb_max_width">9dp</dimen>
|
||||
<dimen name="container_fastscroll_popup_margin">18dp</dimen>
|
||||
|
@ -65,9 +60,6 @@
|
|||
<dimen name="all_apps_button_scale_down">0dp</dimen>
|
||||
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
|
||||
<dimen name="all_apps_search_bar_height">60dp</dimen>
|
||||
<dimen name="all_apps_search_bar_icon_margin_right">4dp</dimen>
|
||||
<dimen name="all_apps_search_bar_icon_margin_top">1dp</dimen>
|
||||
<dimen name="all_apps_list_bottom_padding">8dp</dimen>
|
||||
<dimen name="all_apps_empty_search_message_top_offset">40dp</dimen>
|
||||
<dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
|
||||
<dimen name="all_apps_background_canvas_width">700dp</dimen>
|
||||
|
@ -146,7 +138,7 @@
|
|||
<dimen name="blur_size_medium_outline">2dp</dimen>
|
||||
<dimen name="blur_size_click_shadow">4dp</dimen>
|
||||
<dimen name="click_shadow_high_shift">2dp</dimen>
|
||||
<dimen name="drawable_shadow_size">2dp</dimen>
|
||||
<dimen name="drawable_shadow_size">4dp</dimen>
|
||||
|
||||
<!-- Pending widget -->
|
||||
<dimen name="pending_widget_min_padding">8dp</dimen>
|
||||
|
|
|
@ -113,6 +113,7 @@ public abstract class BaseRecyclerView extends RecyclerView
|
|||
* it is already showing).
|
||||
*/
|
||||
private boolean handleTouchEvent(MotionEvent ev) {
|
||||
ev.offsetLocation(0, -getPaddingTop());
|
||||
int action = ev.getAction();
|
||||
int x = (int) ev.getX();
|
||||
int y = (int) ev.getY();
|
||||
|
@ -136,6 +137,7 @@ public abstract class BaseRecyclerView extends RecyclerView
|
|||
mScrollbar.handleTouchEvent(ev, mDownX, mDownY, mLastY);
|
||||
break;
|
||||
}
|
||||
ev.offsetLocation(0, getPaddingTop());
|
||||
return mScrollbar.isDraggingThumb();
|
||||
}
|
||||
|
||||
|
@ -162,7 +164,7 @@ public abstract class BaseRecyclerView extends RecyclerView
|
|||
* Returns the height of the fast scroll bar
|
||||
*/
|
||||
protected int getScrollbarTrackHeight() {
|
||||
return getHeight();
|
||||
return getHeight() - getPaddingTop() - getPaddingBottom();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -136,6 +136,7 @@ public class BaseRecyclerViewFastScrollBar {
|
|||
mTmpRect.set(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight);
|
||||
mThumbOffsetY = y;
|
||||
mTmpRect.union(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight);
|
||||
mTmpRect.offset(0, mRv.getPaddingTop());
|
||||
mRv.invalidate(mTmpRect);
|
||||
}
|
||||
|
||||
|
@ -148,8 +149,9 @@ public class BaseRecyclerViewFastScrollBar {
|
|||
return;
|
||||
}
|
||||
int left = getDrawLeft();
|
||||
int top = mRv.getPaddingTop();
|
||||
// Invalidate the whole scroll bar area.
|
||||
mRv.invalidate(left, 0, left + mMaxWidth, mRv.getScrollbarTrackHeight());
|
||||
mRv.invalidate(left, top, left + mMaxWidth, top + mRv.getScrollbarTrackHeight());
|
||||
|
||||
mWidth = width;
|
||||
updateThumbPath();
|
||||
|
@ -265,6 +267,7 @@ public class BaseRecyclerViewFastScrollBar {
|
|||
if (!mIsRtl) {
|
||||
canvas.translate(mRv.getWidth(), 0);
|
||||
}
|
||||
canvas.translate(0, mRv.getPaddingTop());
|
||||
// Draw the track
|
||||
int thumbWidth = mIsRtl ? mWidth : -mWidth;
|
||||
canvas.drawRect(0, 0, thumbWidth, mRv.getScrollbarTrackHeight(), mTrackPaint);
|
||||
|
|
|
@ -245,6 +245,10 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
|||
}
|
||||
}
|
||||
|
||||
public SearchUiManager getSearchUiManager() {
|
||||
return mSearchUiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getTouchDelegateTargetView() {
|
||||
return mAppsRecyclerView;
|
||||
|
@ -366,6 +370,10 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
|||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
mAppsRecyclerView.setPadding(
|
||||
mAppsRecyclerView.getPaddingLeft(), mAppsRecyclerView.getPaddingTop(),
|
||||
mAppsRecyclerView.getPaddingRight(), insets.bottom);
|
||||
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
|
||||
mlp.leftMargin = insets.left;
|
||||
|
|
|
@ -161,11 +161,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
|||
}
|
||||
return extraRows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaddingBottom() {
|
||||
return mLauncher.getDragLayer().getInsets().bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -392,21 +392,14 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
|
|||
return getPaddingTop() + y - offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarTrackHeight() {
|
||||
return super.getScrollbarTrackHeight()
|
||||
- Launcher.getLauncher(getContext()).getDragLayer().getInsets().bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the available scroll height:
|
||||
* AvailableScrollHeight = Total height of the all items - last page height
|
||||
*/
|
||||
@Override
|
||||
protected int getAvailableScrollHeight() {
|
||||
int paddedHeight = getCurrentScrollY(mApps.getAdapterItems().size(), 0);
|
||||
int totalHeight = paddedHeight + getPaddingBottom();
|
||||
return totalHeight - getScrollbarTrackHeight();
|
||||
return getCurrentScrollY(mApps.getAdapterItems().size(), 0)
|
||||
- getHeight() + getPaddingBottom();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ import com.android.launcher3.util.TouchController;
|
|||
* closer to top or closer to the page indicator.
|
||||
*/
|
||||
public class AllAppsTransitionController implements TouchController, VerticalPullDetector.Listener,
|
||||
View.OnLayoutChangeListener, ExtractedColors.OnChangeListener {
|
||||
ExtractedColors.OnChangeListener, SearchUiManager.OnScrollRangeChangeListener {
|
||||
|
||||
private static final String TAG = "AllAppsTrans";
|
||||
private static final boolean DBG = false;
|
||||
|
@ -531,21 +531,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
|
|||
mAppsView = appsView;
|
||||
mHotseat = hotseat;
|
||||
mWorkspace = workspace;
|
||||
mHotseat.addOnLayoutChangeListener(this);
|
||||
mHotseat.bringToFront();
|
||||
mCaretController = new AllAppsCaretController(
|
||||
mWorkspace.getPageIndicator().getCaretDrawable(), mLauncher);
|
||||
mAppsView.getSearchUiManager().addOnScrollRangeChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
mShiftRange = top;
|
||||
} else {
|
||||
mShiftRange = bottom;
|
||||
}
|
||||
public void onScrollRangeChanged(int scrollRange) {
|
||||
mShiftRange = scrollRange;
|
||||
setProgress(mProgress);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,14 @@ public interface SearchUiManager {
|
|||
* TODO: Remove when removing support for opening all-apps in search mode.
|
||||
*/
|
||||
void startAppsSearch();
|
||||
|
||||
void addOnScrollRangeChangeListener(OnScrollRangeChangeListener listener);
|
||||
|
||||
/**
|
||||
* Callback for listening to changes in the vertical scroll range when opening all-apps.
|
||||
*/
|
||||
interface OnScrollRangeChangeListener {
|
||||
|
||||
void onScrollRangeChanged(int scrollRange);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.text.TextUtils;
|
|||
import android.text.method.TextKeyListener;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.ExtendedEditText;
|
||||
|
@ -192,4 +193,19 @@ public class AppsSearchContainerLayout extends FrameLayout
|
|||
mElevationController.reset();
|
||||
mAppsRecyclerView.onSearchResultsChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnScrollRangeChangeListener(final OnScrollRangeChangeListener listener) {
|
||||
mLauncher.getHotseat().addOnLayoutChangeListener(new OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
listener.onScrollRangeChanged(top);
|
||||
} else {
|
||||
listener.onScrollRangeChanged(bottom);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue