mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 08:56:55 +00:00
Extract common codes for personal / work profile tabs
These codes can be reused in the FullWidgetsSheet which we will be
adding tabs for personal / work profile.
Test: Set up work profile and then switch person / work profile tabs
in the AllAppsContainerView.
Bug: 179797520
Change-Id: Ib7eb1190e1384a664cbe3e34411c9362f1f6db03
This commit is contained in:
@@ -17,17 +17,17 @@ package com.android.launcher3.allapps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.PagedView;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.workprofile.PersonalWorkPagedView;
|
||||
|
||||
public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
|
||||
|
||||
static final float START_DAMPING_TOUCH_SLOP_ANGLE = (float) Math.PI / 6;
|
||||
static final float MAX_SWIPE_ANGLE = (float) Math.PI / 3;
|
||||
static final float TOUCH_SLOP_DAMPING_FACTOR = 4;
|
||||
/**
|
||||
* A {@link PagedView} for showing different views for the personal and work profile respectively
|
||||
* in the {@link AllAppsContainerView}.
|
||||
*/
|
||||
public class AllAppsPagedView extends PersonalWorkPagedView {
|
||||
|
||||
public AllAppsPagedView(Context context) {
|
||||
this(context, null);
|
||||
@@ -44,52 +44,4 @@ public class AllAppsPagedView extends PagedView<PersonalWorkSlidingTabStrip> {
|
||||
R.dimen.all_apps_header_top_padding);
|
||||
setPadding(0, topPadding, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCurrentPageDescription() {
|
||||
// Not necessary, tab-bar already has two tabs with their own descriptions.
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
super.onScrollChanged(l, t, oldl, oldt);
|
||||
mPageIndicator.setScroll(l, mMaxScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void determineScrollingStart(MotionEvent ev) {
|
||||
float absDeltaX = Math.abs(ev.getX() - getDownMotionX());
|
||||
float absDeltaY = Math.abs(ev.getY() - getDownMotionY());
|
||||
|
||||
if (Float.compare(absDeltaX, 0f) == 0) return;
|
||||
|
||||
float slope = absDeltaY / absDeltaX;
|
||||
float theta = (float) Math.atan(slope);
|
||||
|
||||
if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) {
|
||||
cancelCurrentPageLongPress();
|
||||
}
|
||||
|
||||
if (theta > MAX_SWIPE_ANGLE) {
|
||||
return;
|
||||
} else if (theta > START_DAMPING_TOUCH_SLOP_ANGLE) {
|
||||
theta -= START_DAMPING_TOUCH_SLOP_ANGLE;
|
||||
float extraRatio = (float)
|
||||
Math.sqrt((theta / (MAX_SWIPE_ANGLE - START_DAMPING_TOUCH_SLOP_ANGLE)));
|
||||
super.determineScrollingStart(ev, 1 + TOUCH_SLOP_DAMPING_FACTOR * extraRatio);
|
||||
} else {
|
||||
super.determineScrollingStart(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canScroll(float absVScroll, float absHScroll) {
|
||||
return (absHScroll > absVScroll) && super.canScroll(absVScroll, absHScroll);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user