Tweaking the apps list fast scroller.

- Making the view span the full width so that you can grab the scroller on the edge of the screen.
- Offsetting the fast-scoll popup so that you can see it as you scrub.

Change-Id: If1b1934bbeac0660d829cfc29c9e588df927c5e5
This commit is contained in:
Winson Chung
2015-03-16 12:39:05 -07:00
parent c13b994c04
commit aa2ab254ea
14 changed files with 114 additions and 30 deletions
@@ -37,6 +37,8 @@ import java.util.List;
public class AppsContainerRecyclerView extends RecyclerView
implements RecyclerView.OnItemTouchListener {
private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 1.5f;
private AlphabeticalAppsList mApps;
private int mNumAppsPerRow;
@@ -130,7 +132,7 @@ public class AppsContainerRecyclerView extends RecyclerView
} else {
x = getWidth() - getPaddingRight() - getScrollBarSize() - bgBounds.width();
}
int y = mLastY - bgBounds.height() / 2;
int y = mLastY - (int) (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * bgBounds.height());
y = Math.max(getPaddingTop(), Math.min(y, getHeight() - getPaddingBottom() -
bgBounds.height()));
canvas.translate(x, y);
@@ -39,9 +39,9 @@ import java.util.List;
/**
* The all apps list view container.
*/
public class AppsContainerView extends FrameLayout implements DragSource, View.OnTouchListener,
View.OnLongClickListener, Insettable, TextWatcher, TextView.OnEditorActionListener,
LauncherTransitionable {
public class AppsContainerView extends FrameLayout implements DragSource, Insettable, TextWatcher,
TextView.OnEditorActionListener, LauncherTransitionable, View.OnTouchListener,
View.OnLongClickListener {
private static final boolean ALLOW_SINGLE_APP_LAUNCH = true;
@@ -188,10 +188,10 @@ public class AppsContainerView extends FrameLayout implements DragSource, View.O
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN ||
event.getAction() == MotionEvent.ACTION_MOVE) {
mLastTouchDownPos.set((int) event.getX(), (int) event.getY());
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN ||
ev.getAction() == MotionEvent.ACTION_MOVE) {
mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY());
}
return false;
}
@@ -333,7 +333,6 @@ public class AppsContainerView extends FrameLayout implements DragSource, View.O
List<AppInfo> appsWithoutSections = mApps.getAppsWithoutSectionBreaks();
List<AppInfo> apps = mApps.getApps();
if (appsWithoutSections.size() == 1) {
mSearchBar.clearFocus();
mAppsListView.getChildAt(apps.indexOf(appsWithoutSections.get(0))).performClick();
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -84,12 +84,13 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
mSectionTextPaint.getTextBounds(section, 0, section.length(),
mTmpBounds);
if (mIsRtl) {
c.drawText(section, parent.getWidth() - mStartMargin +
(mStartMargin - mTmpBounds.width()) / 2,
int left = parent.getWidth() - mPaddingStart - mStartMargin;
c.drawText(section, left + (mStartMargin - mTmpBounds.width()) / 2,
child.getTop() + (2 * child.getPaddingTop()) +
mTmpBounds.height(), mSectionTextPaint);
} else {
c.drawText(section, (mStartMargin - mTmpBounds.width()) / 2,
int left = mPaddingStart;
c.drawText(section, left + (mStartMargin - mTmpBounds.width()) / 2,
child.getTop() + (2 * child.getPaddingTop()) +
mTmpBounds.height(), mSectionTextPaint);
}
@@ -118,6 +119,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
private String mEmptySearchText;
// Section drawing
private int mPaddingStart;
private int mStartMargin;
private Paint mSectionTextPaint;
private Rect mTmpBounds = new Rect();
@@ -136,6 +138,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
mIconClickListener = iconClickListener;
mIconLongClickListener = iconLongClickListener;
mStartMargin = res.getDimensionPixelSize(R.dimen.apps_grid_view_start_margin);
mPaddingStart = res.getDimensionPixelSize(R.dimen.apps_container_inset);
mSectionTextPaint = new Paint();
mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
R.dimen.apps_view_section_text_size));