diff options
Diffstat (limited to 'src/com/android/launcher3')
8 files changed, 47 insertions, 26 deletions
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java index c05633615..1e6d89485 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/BaseRecyclerView.java @@ -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(); } /** diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java index 5feb42ea8..303974464 100644 --- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java +++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java @@ -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); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 0ea61f430..d9ee2c55a 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -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; diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index e12610257..cfd04e2e0 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -161,11 +161,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. } return extraRows; } - - @Override - public int getPaddingBottom() { - return mLauncher.getDragLayer().getInsets().bottom; - } } /** diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index f3089d2cd..16b2bd1fc 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -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(); } /** diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 9c1854a36..97aa54ac5 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -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); } - } diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java index 15455bcc3..0d013c73f 100644 --- a/src/com/android/launcher3/allapps/SearchUiManager.java +++ b/src/com/android/launcher3/allapps/SearchUiManager.java @@ -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); + } } diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index 116ec8866..f785e4cdb 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -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); + } + } + }); + } } |