Merge changes from topic "allapps_bottomsheet_motion" into tm-dev am: d8f81e9bf4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16967984 Change-Id: I529406e91a0328b28fbfe18c930b795cacfdb3f0
This commit is contained in:
@@ -23,6 +23,7 @@ import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.views.AbstractSlideInView;
|
||||
@@ -30,14 +31,14 @@ import com.android.launcher3.views.AbstractSlideInView;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Wrapper for taskbar all apps with slide-in behavior. */
|
||||
public class TaskbarAllAppsSlideInView extends
|
||||
AbstractSlideInView<TaskbarAllAppsContext> implements Insettable {
|
||||
|
||||
public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllAppsContext>
|
||||
implements Insettable, DeviceProfile.OnDeviceProfileChangeListener {
|
||||
static final int DEFAULT_OPEN_DURATION = 500;
|
||||
static final int DEFAULT_CLOSE_DURATION = 200;
|
||||
|
||||
private TaskbarAllAppsContainerView mAppsView;
|
||||
private OnCloseListener mOnCloseBeginListener;
|
||||
private float mShiftRange;
|
||||
|
||||
public TaskbarAllAppsSlideInView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
@@ -88,6 +89,11 @@ public class TaskbarAllAppsSlideInView extends
|
||||
super.onFinishInflate();
|
||||
mAppsView = findViewById(R.id.apps_view);
|
||||
mContent = mAppsView;
|
||||
|
||||
DeviceProfile dp = mActivityContext.getDeviceProfile();
|
||||
setShiftRange(dp.allAppsShiftRange);
|
||||
|
||||
mActivityContext.addOnDeviceProfileChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,4 +119,24 @@ public class TaskbarAllAppsSlideInView extends
|
||||
public void setInsets(Rect insets) {
|
||||
mAppsView.setInsets(insets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||
setShiftRange(dp.allAppsShiftRange);
|
||||
setTranslationShift(TRANSLATION_SHIFT_OPENED);
|
||||
}
|
||||
|
||||
private void setShiftRange(float shiftRange) {
|
||||
mShiftRange = shiftRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getShiftRange() {
|
||||
return mShiftRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEventOverContent(MotionEvent ev) {
|
||||
return getPopupContainer().isEventOverView(mAppsView.getVisibleContainerView(), ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,16 @@ public class AllAppsState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
||||
ScaleAndTranslation scaleAndTranslation = LauncherState.OVERVIEW
|
||||
.getWorkspaceScaleAndTranslation(launcher);
|
||||
scaleAndTranslation.scale = 1;
|
||||
ScaleAndTranslation scaleAndTranslation =
|
||||
new ScaleAndTranslation(NO_SCALE, NO_OFFSET, NO_OFFSET);
|
||||
if (launcher.getDeviceProfile().isTablet) {
|
||||
scaleAndTranslation.scale = 0.97f;
|
||||
} else {
|
||||
ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW
|
||||
.getWorkspaceScaleAndTranslation(launcher);
|
||||
scaleAndTranslation.translationX = overviewScaleAndTranslation.translationX;
|
||||
scaleAndTranslation.translationY = overviewScaleAndTranslation.translationY;
|
||||
}
|
||||
return scaleAndTranslation;
|
||||
}
|
||||
|
||||
|
||||
+19
-6
@@ -23,8 +23,13 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
|
||||
import static com.android.launcher3.anim.Interpolators.INSTANT;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR_TELEPORT;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@@ -126,23 +131,31 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
|
||||
|
||||
private StateAnimationConfig getNormalToAllAppsAnimation() {
|
||||
StateAnimationConfig builder = new StateAnimationConfig();
|
||||
builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL,
|
||||
ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD,
|
||||
ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD));
|
||||
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
|
||||
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
|
||||
? INSTANT
|
||||
: Interpolators.clampToProgress(ACCEL,
|
||||
ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD,
|
||||
ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD));
|
||||
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(ACCEL,
|
||||
ALL_APPS_SCRIM_VISIBLE_THRESHOLD,
|
||||
ALL_APPS_SCRIM_OPAQUE_THRESHOLD));
|
||||
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
|
||||
return builder;
|
||||
}
|
||||
|
||||
private StateAnimationConfig getAllAppsToNormalAnimation() {
|
||||
StateAnimationConfig builder = new StateAnimationConfig();
|
||||
builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL,
|
||||
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
|
||||
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
|
||||
boolean isTablet = mLauncher.getDeviceProfile().isTablet;
|
||||
builder.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
|
||||
? FINAL_FRAME
|
||||
: Interpolators.clampToProgress(DEACCEL,
|
||||
1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD,
|
||||
1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
|
||||
builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL,
|
||||
1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD,
|
||||
1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
|
||||
builder.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<solid android:color="@color/surface" />
|
||||
<solid android:color="?android:attr/colorBackground" />
|
||||
<corners
|
||||
android:topLeftRadius="@dimen/dialogCornerRadius"
|
||||
android:topRightRadius="@dimen/dialogCornerRadius" />
|
||||
|
||||
+8
-15
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2022 The Android Open Source Project
|
||||
<!-- Copyright (C) 2022 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,16 +13,10 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<ripple android:color="?android:attr/colorControlHighlight"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle"
|
||||
android:tint="?colorButtonNormal">
|
||||
<corners
|
||||
android:topLeftRadius="@dimen/dialogCornerRadius"
|
||||
android:topRightRadius="@dimen/dialogCornerRadius"/>
|
||||
<solid android:color="?attr/allAppsScrimColor" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle" >
|
||||
<solid android:color="?androidprv:attr/colorSurfaceVariant"/>
|
||||
<corners android:radius="@dimen/bottom_sheet_handle_corner_radius" />
|
||||
</shape>
|
||||
@@ -17,19 +17,19 @@
|
||||
android:id="@+id/bottom_sheet_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_all_apps_bottom_sheet">
|
||||
android:background="@drawable/bg_rounded_corner_bottom_sheet">
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_sheet_handle_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="34dp" />
|
||||
android:layout_height="36dp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_sheet_handle"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="2dp"
|
||||
android:layout_width="@dimen/bottom_sheet_handle_width"
|
||||
android:layout_height="@dimen/bottom_sheet_handle_height"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="?android:attr/textColorSecondary" />
|
||||
android:layout_marginTop="@dimen/bottom_sheet_handle_margin"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_handle_margin"
|
||||
android:background="@drawable/bg_rounded_corner_bottom_sheet_handle" />
|
||||
</FrameLayout>
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_rounded_corner_bottom_sheet"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingTop="@dimen/bottom_sheet_handle_margin"
|
||||
android:orientation="vertical">
|
||||
<View
|
||||
android:id="@+id/collapse_handle"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="2dp"
|
||||
android:layout_width="@dimen/bottom_sheet_handle_width"
|
||||
android:layout_height="@dimen/bottom_sheet_handle_height"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_handle_margin"
|
||||
android:visibility="gone"
|
||||
android:background="?android:attr/textColorSecondary"/>
|
||||
android:background="@drawable/bg_rounded_corner_bottom_sheet_handle"/>
|
||||
<TextView
|
||||
style="@style/TextHeadline"
|
||||
android:id="@+id/title"
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
|
||||
<View
|
||||
android:id="@+id/collapse_handle"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="2dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_width="@dimen/bottom_sheet_handle_width"
|
||||
android:layout_height="@dimen/bottom_sheet_handle_height"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_handle_margin"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="?android:attr/textColorSecondary"/>
|
||||
android:background="@drawable/bg_rounded_corner_bottom_sheet_handle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/no_widgets_text"
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
<dimen name="widget_list_horizontal_margin">32dp</dimen>
|
||||
|
||||
<!-- AllApps -->
|
||||
<dimen name="all_apps_bottom_sheet_horizontal_padding">32dp</dimen>
|
||||
<dimen name="all_apps_search_bar_content_overlap">0dp</dimen>
|
||||
<dimen name="all_apps_bottom_sheet_horizontal_padding">46dp</dimen>
|
||||
|
||||
<!-- Fast scroll -->
|
||||
<dimen name="fastscroll_popup_width">75dp</dimen>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2022 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at`
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- AllApps -->
|
||||
<dimen name="all_apps_top_padding">0dp</dimen>
|
||||
</resources>
|
||||
@@ -16,5 +16,6 @@
|
||||
|
||||
<resources>
|
||||
<!-- AllApps -->
|
||||
<dimen name="all_apps_bottom_sheet_horizontal_padding">41dp</dimen>
|
||||
<dimen name="all_apps_top_padding">300dp</dimen>
|
||||
<dimen name="all_apps_bottom_sheet_horizontal_padding">65dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -93,8 +93,11 @@
|
||||
<dimen name="fastscroll_end_margin">-26dp</dimen>
|
||||
|
||||
<!-- All Apps -->
|
||||
<dimen name="all_apps_open_vertical_translate">320dp</dimen>
|
||||
<dimen name="all_apps_starting_vertical_translate">320dp</dimen>
|
||||
<dimen name="all_apps_top_padding">0dp</dimen>
|
||||
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
|
||||
<!-- all_apps_search_bar_field_height / 2 -->
|
||||
<dimen name="all_apps_search_bar_content_overlap">24dp</dimen>
|
||||
<dimen name="all_apps_search_bar_bottom_padding">30dp</dimen>
|
||||
<dimen name="all_apps_empty_search_message_top_offset">40dp</dimen>
|
||||
<dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
|
||||
@@ -363,4 +366,9 @@
|
||||
<dimen name="search_row_small_icon_size">32dp</dimen>
|
||||
<dimen name="padded_rounded_button_padding">8dp</dimen>
|
||||
|
||||
<!-- Bottom sheet related parameters -->
|
||||
<dimen name="bottom_sheet_handle_width">32dp</dimen>
|
||||
<dimen name="bottom_sheet_handle_height">4dp</dimen>
|
||||
<dimen name="bottom_sheet_handle_margin">16dp</dimen>
|
||||
<dimen name="bottom_sheet_handle_corner_radius">2dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -171,7 +171,8 @@ public class DeviceProfile {
|
||||
|
||||
// All apps
|
||||
public Point allAppsBorderSpacePx;
|
||||
public int allAppsOpenVerticalTranslate;
|
||||
public int allAppsShiftRange;
|
||||
public int allAppsTopPadding;
|
||||
public int allAppsCellHeightPx;
|
||||
public int allAppsCellWidthPx;
|
||||
public int allAppsIconSizePx;
|
||||
@@ -288,8 +289,11 @@ public class DeviceProfile {
|
||||
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
|
||||
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
|
||||
|
||||
allAppsOpenVerticalTranslate = res.getDimensionPixelSize(
|
||||
R.dimen.all_apps_open_vertical_translate);
|
||||
allAppsTopPadding = res.getDimensionPixelSize(R.dimen.all_apps_top_padding)
|
||||
+ (isTablet ? heightPx - availableHeightPx : 0);
|
||||
allAppsShiftRange = isTablet
|
||||
? heightPx - allAppsTopPadding
|
||||
: res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
|
||||
|
||||
folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
|
||||
folderContentPaddingLeftRight =
|
||||
|
||||
@@ -89,15 +89,15 @@ public class AllAppsTransitionController
|
||||
private float mShiftRange; // changes depending on the orientation
|
||||
private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent
|
||||
|
||||
private float mScrollRangeDelta = 0;
|
||||
private ScrimView mScrimView;
|
||||
|
||||
public AllAppsTransitionController(Launcher l) {
|
||||
mLauncher = l;
|
||||
mShiftRange = mLauncher.getDeviceProfile().heightPx;
|
||||
DeviceProfile dp = mLauncher.getDeviceProfile();
|
||||
setShiftRange(dp.allAppsShiftRange);
|
||||
mProgress = 1f;
|
||||
|
||||
mIsVerticalLayout = mLauncher.getDeviceProfile().isVerticalBarLayout();
|
||||
mIsVerticalLayout = dp.isVerticalBarLayout();
|
||||
mLauncher.addOnDeviceProfileChangeListener(this);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class AllAppsTransitionController
|
||||
@Override
|
||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||
mIsVerticalLayout = dp.isVerticalBarLayout();
|
||||
setScrollRangeDelta(mScrollRangeDelta);
|
||||
setShiftRange(dp.allAppsShiftRange);
|
||||
|
||||
if (mIsVerticalLayout) {
|
||||
mLauncher.getHotseat().setTranslationY(0);
|
||||
@@ -160,12 +160,14 @@ public class AllAppsTransitionController
|
||||
}
|
||||
|
||||
// need to decide depending on the release velocity
|
||||
Interpolator interpolator = (config.userControlled ? LINEAR : DEACCEL_1_7);
|
||||
|
||||
Interpolator verticalProgressInterpolator = config.getInterpolator(ANIM_VERTICAL_PROGRESS,
|
||||
config.userControlled ? LINEAR : DEACCEL_1_7);
|
||||
Animator anim = createSpringAnimation(mProgress, targetProgress);
|
||||
anim.setInterpolator(config.getInterpolator(ANIM_VERTICAL_PROGRESS, interpolator));
|
||||
anim.setInterpolator(verticalProgressInterpolator);
|
||||
anim.addListener(getProgressAnimatorListener());
|
||||
builder.add(anim);
|
||||
// Use ANIM_VERTICAL_PROGRESS's interpolator to determine state transition threshold.
|
||||
builder.setInterpolator(verticalProgressInterpolator);
|
||||
|
||||
setAlphas(toState, config, builder);
|
||||
|
||||
@@ -215,9 +217,8 @@ public class AllAppsTransitionController
|
||||
/**
|
||||
* Updates the total scroll range but does not update the UI.
|
||||
*/
|
||||
public void setScrollRangeDelta(float delta) {
|
||||
mScrollRangeDelta = delta;
|
||||
mShiftRange = mLauncher.getDeviceProfile().heightPx - mScrollRangeDelta;
|
||||
public void setShiftRange(float shiftRange) {
|
||||
mShiftRange = shiftRange;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,7 +408,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
|
||||
} else {
|
||||
setPadding(0, grid.isTablet ? insets.top : 0, 0, 0);
|
||||
setPadding(0, grid.allAppsTopPadding, 0, 0);
|
||||
}
|
||||
|
||||
InsettableFrameLayout.dispatchInsets(this, insets);
|
||||
@@ -765,4 +765,11 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
&& mVerticalFadingEdge);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that denotes the visible part of all apps container view.
|
||||
*/
|
||||
public View getVisibleContainerView() {
|
||||
return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@@ -59,12 +58,4 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsets(Rect insets) {
|
||||
super.setInsets(insets);
|
||||
int allAppsStartingPositionY = mActivityContext.getDeviceProfile().availableHeightPx
|
||||
- mActivityContext.getDeviceProfile().allAppsOpenVerticalTranslate;
|
||||
mActivityContext.getAllAppsController().setScrollRangeDelta(allAppsStartingPositionY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
||||
setHint(prefixTextWithIcon(getContext(), R.drawable.ic_allapps_search, getHint()));
|
||||
|
||||
mContentOverlap =
|
||||
getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_field_height) / 2;
|
||||
getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_content_overlap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -130,6 +130,23 @@ public class Interpolators {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Interpolator LINEAR_TELEPORT = t -> {
|
||||
float startTeleport = 0.2f;
|
||||
float endTeleport = 0.4f;
|
||||
float teleportProgress = 0.5f;
|
||||
float v;
|
||||
if (t < startTeleport) {
|
||||
v = LINEAR.getInterpolation(t);
|
||||
} else if (t < endTeleport) {
|
||||
v = Utilities.mapToRange(t, startTeleport, endTeleport, startTeleport,
|
||||
endTeleport + teleportProgress, ACCEL_DEACCEL);
|
||||
} else {
|
||||
v = LINEAR.getInterpolation(t) + teleportProgress;
|
||||
}
|
||||
v = Utilities.boundToRange(v, 0f, 1f);
|
||||
return v;
|
||||
};
|
||||
|
||||
private static final float FAST_FLING_PX_MS = 10;
|
||||
|
||||
public static Interpolator scrollInterpolatorForVelocity(float velocity) {
|
||||
|
||||
@@ -77,6 +77,13 @@ public class PendingAnimation implements PropertySetter {
|
||||
addAnimationHoldersRecur(a, mDuration, springProperty, mAnimHolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures interpolator of the underlying AnimatorSet.
|
||||
*/
|
||||
public void setInterpolator(TimeInterpolator interpolator) {
|
||||
mAnim.setInterpolator(interpolator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
|
||||
if (view == null || view.getAlpha() == alpha) {
|
||||
|
||||
@@ -17,9 +17,13 @@ package com.android.launcher3.touch;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
|
||||
import static com.android.launcher3.anim.Interpolators.INSTANT;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR_TELEPORT;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
import android.view.animation.Interpolator;
|
||||
@@ -94,9 +98,9 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
|
||||
LauncherState toState) {
|
||||
StateAnimationConfig config = super.getConfigForStates(fromState, toState);
|
||||
if (fromState == NORMAL && toState == ALL_APPS) {
|
||||
applyNormalToAllAppsAnimConfig(config);
|
||||
applyNormalToAllAppsAnimConfig(mLauncher, config);
|
||||
} else if (fromState == ALL_APPS && toState == NORMAL) {
|
||||
applyAllAppsToNormalConfig(config);
|
||||
applyAllAppsToNormalConfig(mLauncher, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
@@ -104,17 +108,24 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController {
|
||||
/**
|
||||
* Applies Animation config values for transition from all apps to home
|
||||
*/
|
||||
public static void applyAllAppsToNormalConfig(StateAnimationConfig config) {
|
||||
public static void applyAllAppsToNormalConfig(Launcher launcher, StateAnimationConfig config) {
|
||||
boolean isTablet = launcher.getDeviceProfile().isTablet;
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
|
||||
? FINAL_FRAME : ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies Animation config values for transition from home to all apps
|
||||
*/
|
||||
public static void applyNormalToAllAppsAnimConfig(StateAnimationConfig config) {
|
||||
public static void applyNormalToAllAppsAnimConfig(Launcher launcher,
|
||||
StateAnimationConfig config) {
|
||||
boolean isTablet = launcher.getDeviceProfile().isTablet;
|
||||
config.setInterpolator(ANIM_SCRIM_FADE, ALLAPPS_STAGGERED_FADE_EARLY_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
|
||||
config.setInterpolator(ANIM_ALL_APPS_FADE, isTablet
|
||||
? INSTANT : ALLAPPS_STAGGERED_FADE_LATE_RESPONDER);
|
||||
config.setInterpolator(ANIM_VERTICAL_PROGRESS, isTablet ? LINEAR_TELEPORT : LINEAR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,9 +113,16 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range in height that the slide in view can be dragged.
|
||||
*/
|
||||
protected float getShiftRange() {
|
||||
return mContent.getHeight();
|
||||
}
|
||||
|
||||
protected void setTranslationShift(float translationShift) {
|
||||
mTranslationShift = translationShift;
|
||||
mContent.setTranslationY(mTranslationShift * mContent.getHeight());
|
||||
mContent.setTranslationY(mTranslationShift * getShiftRange());
|
||||
if (mColorScrim != null) {
|
||||
mColorScrim.setAlpha(1 - mTranslationShift);
|
||||
}
|
||||
@@ -132,8 +139,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
|
||||
mSwipeDetector.setDetectableScrollConditions(
|
||||
directionsToDetectScroll, false);
|
||||
mSwipeDetector.onTouchEvent(ev);
|
||||
return mSwipeDetector.isDraggingOrSettling()
|
||||
|| !getPopupContainer().isEventOverView(mContent, ev);
|
||||
return mSwipeDetector.isDraggingOrSettling() || !isEventOverContent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,13 +148,23 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
|
||||
if (ev.getAction() == MotionEvent.ACTION_UP && mSwipeDetector.isIdleState()
|
||||
&& !isOpeningAnimationRunning()) {
|
||||
// If we got ACTION_UP without ever starting swipe, close the panel.
|
||||
if (!getPopupContainer().isEventOverView(mContent, ev)) {
|
||||
if (!isEventOverContent(ev)) {
|
||||
close(true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the touch event is over the visible area of the bottom sheet.
|
||||
*
|
||||
* By default will check if the touch event is over {@code mContent}, subclasses should override
|
||||
* this method if the visible area of the bottom sheet is different from {@code mContent}.
|
||||
*/
|
||||
protected boolean isEventOverContent(MotionEvent ev) {
|
||||
return getPopupContainer().isEventOverView(mContent, ev);
|
||||
}
|
||||
|
||||
private boolean isOpeningAnimationRunning() {
|
||||
return mIsOpen && mOpenCloseAnimator.isRunning();
|
||||
}
|
||||
@@ -160,7 +176,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
|
||||
|
||||
@Override
|
||||
public boolean onDrag(float displacement) {
|
||||
float range = mContent.getHeight();
|
||||
float range = getShiftRange();
|
||||
displacement = Utilities.boundToRange(displacement, 0, range);
|
||||
setTranslationShift(displacement / range);
|
||||
return true;
|
||||
|
||||
@@ -55,8 +55,15 @@ public class AllAppsState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
||||
return new ScaleAndTranslation(1f, 0,
|
||||
-launcher.getAllAppsController().getShiftRange() * PARALLAX_COEFFICIENT);
|
||||
ScaleAndTranslation scaleAndTranslation =
|
||||
new ScaleAndTranslation(NO_SCALE, NO_OFFSET, NO_OFFSET);
|
||||
if (launcher.getDeviceProfile().isTablet) {
|
||||
scaleAndTranslation.scale = 0.97f;
|
||||
} else {
|
||||
scaleAndTranslation.translationY =
|
||||
-launcher.getAllAppsController().getShiftRange() * PARALLAX_COEFFICIENT;
|
||||
}
|
||||
return scaleAndTranslation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user